package com.zzq.my.jetpacks.jectpackapp.ui

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.dsl.addTextChangedListenerDsl
import com.zzq.my.jetpacks.jectpackapp.dsl.buildSpannableString
import kotlinx.coroutines.*

class TestActivity : AppCompatActivity() {

    val ms = MainScope()

    @OptIn(DelicateCoroutinesApi::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test)

    val tv1 = findViewById<TextView>(R.id.textView1)
        tv1.addTextChangedListenerDsl {
           afterTextChangedDsl {

           }
        }

        tv1.buildSpannableString {
            addText("干一行；行一行；一行行；行行行")
            addText("<<隐私协议>>"){
                setColor("#0094ff")
                onClick(true)
                {
                    //todo.......
                }
            }
            addText("abc")
        }

        ms.launch {

        }
        ms.cancel()


        GlobalScope.async {
            val withContext:String = withContext(Dispatchers.IO)
            {
                ""
            }
            withContext
        }

        lifecycleScope.launch {
            testCorutineScope();
        }


    }

    private suspend fun testCorutineScope()
    {
        val async = CoroutineScope(Dispatchers.IO).async {
            "xxxxxx"
        }.await()
    }
}